﻿using System;
using System.Collections;
using System.Collections.Generic;
using LitJson;
using UnityEngine;

public class RegisterRequest : BaseRequest
{
	private RegisterPanel _registerPanel;
	
	
	protected override void Awake()
	{
		_controllerType = ControllerType.USER;
		_methodType = MethodType.EXECUTE_REGISTER;
		base.Awake();
	}
	
	void Start ()
	{
		_registerPanel = this.gameObject.GetComponent<RegisterPanel>();
	}
	
	// Update is called once per frame
	void Update () {
		
	}

	public override void OnResponse(string data)
	{
		JsonData jsonData = JsonMapper.ToObject(data);
		_registerPanel.HandleRegisterResponse(jsonData);

	}

	public void SendRequest(String nick, String phone, String password)
	{
		JsonData jsonData = new JsonData();
		jsonData["nick"] = nick;
		jsonData["phone"] = phone;
		jsonData["password"] = password;
		NettyRequest nettyRequest = new NettyRequest();
		nettyRequest.controllerType = (int) _controllerType;
		nettyRequest.methodType = (int) _methodType;
		nettyRequest.data = jsonData.ToJson();
		byte[] dataBytes = ConverterTool.SerialRequestObj(nettyRequest);
		UnityFacade.Instance.ClientManager.SendMsgToServer(dataBytes);
	}
	
	// Use this for initialization
	
}
